
import XRDDirSelector from './components/XRDDirSelector/index'
import IntersectionWithInterface from './components/IntersectionWithInterface/index'
import IntersectionMap from './components/IntersectionMap/index'
import SchemeConfig from './components/SchemeConfig/index'
import lockingPhaselControlModal from './components/SchemeConfig/lockingPhaselControlModal/index'
import Channelization from './components/Channelization/index'
import ChannelizationFlowStatistic from './components/ChannelizationFlowStatistic/index'
import DrawChannelization from './components/DrawChannelization/index'
import FaultDetailModal from './components/FaultDetailModal/index'
import CommonKanban from './components/CommonKanban/index'
import patternList from './components/patternList/index'
import PatternStatus from './components/PatternStatus/index'
import BoardCard from './components/BoardCard/index'
import StageStatus from './components/StageStatus/index'
import OverLap from './components/OverLap/index'
import Stages from './components/Stages/index'
import PhaseMarker from './components/PhaseMarker/index'
import overView from './components/overView/index'
import KanBan from './components/KanBan/index'
import StageBord from './components/StageBord/index'
import ExpendConfig from './components/ExpendConfig/index'
import PatternWalkSvg from './components/PatternWalkSvg/index'
import tentativeplancontrolmodal from './components/SchemeConfig/tentativeplancontrolmodal/index'
import priorityControl from './components/SchemeConfig/priorityControl/index'
import { setToken, setHost, setIsCheckPermission, setUserRoles, setPermissions } from '../utils/auth.js'
import componentsGlobalParam from '../store/modules/globalParam'

import en from '../i18n/language/en'
import zh from '../i18n/language/zh'
// 第三方插件
import VTooltip from 'v-tooltip'

const components = {
  XRDDirSelector,
  IntersectionWithInterface,
  IntersectionMap,
  SchemeConfig,
  lockingPhaselControlModal,
  Channelization,
  ChannelizationFlowStatistic,
  DrawChannelization,
  FaultDetailModal,
  PatternStatus,
  BoardCard,
  OverLap,
  StageStatus,
  patternList,
  CommonKanban,
  Stages,
  PhaseMarker,
  overView,
  KanBan,
  StageBord,
  ExpendConfig,
  PatternWalkSvg,
  priorityControl,
  tentativeplancontrolmodal
}

const language = {
  en,
  zh
}

const func = {
  setHost,
  setToken,
  setUserRoles,
  setPermissions,
  setIsCheckPermission
}

const Store = {
  componentsGlobalParam
}

const requireAll = requireContext => requireContext.keys().map(requireContext)
const install = function (Vue) {
  if (install.installed) return
  Vue.use(VTooltip)
  // components.map(component => Vue.component(component.name, component))
  Object.keys(components).forEach(key => {
    Vue.component(components[key].name, components[key])
  })

  const req = require.context('../icons/svg', false, /\.svg$/)
  requireAll(req)

  const urlMgr = require('../lib/publicjs/HttpurlMgr')
  if (urlMgr.HttpUrlMgr.urlMap === undefined) {
    let data = require('../../static/apiconfig.json')
    urlMgr.HttpUrlMgr.init(data)
  }
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

const API = {
  install,
  ...components,
  language,
  func,
  Store
}

export default API
